<!DOCTYPE html>
<html lang="ch-CN">
<head>
    <meta charset="UTF-8">
    <title>创建对象-2</title>
</head>
<style>
    body {
        width: 100%;
        height: 100vh;
        background-color: wheat;
        font-size: 30px;
        text-decoration: none;
        font-family: "华文楷体";
    }
</style>
<script>
    // 创建对象
    /*
      * 使用对象字面量创建对象
    */
    let obj = {}
    obj.name = "小红"
    obj.age = "12"
    obj.gender = "女"
    document.write("name:"+obj.name+"<br>")
    document.write("age:"+obj.age+"<br>")
    document.write("gender:"+obj.gender+"<br>"+"<br>")

    /*
      * 使用对象字面量创建对象 同时添加对象属性
    */
    let obj1 = {
        name:"小明",
        age:"55",
        gender:"男",
        test:{
            name:"二小明",
            age:"22",
            gender:"女"
        }
    }
    document.write("name:"+obj1.name+"<br>")
    document.write("age:"+obj1.age+"<br>")
    document.write("gender:"+obj1.gender+"<br>")
    document.write("test-name:"+obj1.test.name+"<br>")
    document.write("test-age:"+obj1.test.age+"<br>")
    document.write("test-gender:"+obj1.test.gender+"<br>"+"<br>")
</script>
<body>
</body>
</html>